/**
    创建学生类，学生对象具有姓名name，学号numb成绩score属性，
    创建StudentManager学生管理类，封装添加学生addStudent，删除学生deleteStudent，
    查看所有学生showAllStudent功能。
 */
var Student = /** @class */ (function () {
    function Student(name, num, score) {
        this.name = name;
        this.num = num;
        this.score = score;
    }
    Student.prototype.setName = function (name) {
        this.name = name;
    };
    Student.prototype.getName = function () {
        return this.name;
    };
    return Student;
}());
// const stu1 = new Student('jack',1001,98)
// stu1.setName('rose')
// console.log(stu1.getName())
var StudentManager = /** @class */ (function () {
    function StudentManager() {
        this.studentList = [];
    }
    /**
     *  添加学生
     */
    StudentManager.prototype.addStudent = function (name, num, score) {
        var stu = new Student(name, num, score);
        this.studentList.push(stu);
        console.log('添加学生成功！');
    };
    /**
     *  删除学生
     *  删除数组中某元素 [1,2,3,4,5]
     *   filter()
     *   splice(index,count)
     *     根据学号查找索引号  findIndex()  map find  reduce filter every some
     */
    StudentManager.prototype.deleteStudent = function (num) {
        // 查找学号等于传入参数学号的学生在学生数组中索引号
        var index = this.studentList.findIndex(function (stu) { return stu.num == num; });
        if (index == -1) {
            console.log('删除的学生不存在!');
            return;
        }
        this.studentList.splice(index, 1);
        console.log('删除学生成功！');
    };
    /**
     * 显示所有学生
     */
    StudentManager.prototype.showAllStudent = function () {
        this.studentList.forEach(function (stu) {
            console.log("\u59D3\u540D: ".concat(stu.name, " \u5B66\u53F7: ").concat(stu.num, " \u6210\u7EE9: ").concat(stu.score));
        });
    };
    return StudentManager;
}());
var StudentManagerTest = /** @class */ (function () {
    function StudentManagerTest() {
    }
    StudentManagerTest.main = function () {
        var studentManager = new StudentManager();
        // 添加三个学生
        studentManager.addStudent('jack', 1001, 98);
        studentManager.addStudent('rose', 1002, 88);
        studentManager.addStudent('tom', 1001, 79);
        studentManager.showAllStudent(); //显示所有学生
        studentManager.deleteStudent(1001); //删除学号为1001学生
    };
    return StudentManagerTest;
}());
StudentManagerTest.main(); // 入口
